package com.health.db.dao.user.impl;

import java.util.ArrayList;
import java.util.List;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.user.IGoodsPriceListDao;
import com.health.db.mapper.GoodsPriceListMapper;
import com.health.db.model.GoodsPriceList;
import com.health.db.model.GoodsPriceListTemp;
import com.health.redis.RedisConstants;

public class GoodsPriceListDaoImpl extends ServiceInterface implements
		IGoodsPriceListDao {

	GoodsPriceListMapper goodsPriceListMapper;
	private String selectByGoodsIdDocId1 =":columnId:";
	private String selectByGoodsIdDocId2 =":serialIdNo:";
	private String selectByGoodsIdDocId3 =":goodsId:";
	
	/**
	 * 查询商品相关信息 
	 * example object
	 * {goodsid 商品编号
	 *  serialIdno 医生id userid	
	 *  columnid   列   1医生收款  2用户付款
	 * }
	 */
	@Override
	public List<GoodsPriceListTemp> selectByGoodsIdDocId(GoodsPriceList example) {
		getRedisOperatiorLogic();
		String key = RedisConstants.GoodsPriceListMapper
				+ selectByGoodsIdDocId1 + example.getColumnid()
				+ selectByGoodsIdDocId2 + example.getSerialIdno()
				+ selectByGoodsIdDocId3 + example.getGoodsid();

		List<GoodsPriceListTemp> list = new ArrayList<GoodsPriceListTemp>();

		Object object = null;

		if (redisOperatiorLogic.isJedisIsConnected()) {

			object = redisOperatiorLogic.readObject(key,getPublicRedisGroupNo("1"));
		}

		if (null != object ) {
			if (!object.equals("")) {
				list = (List<GoodsPriceListTemp>) object;
			}
		} else {

			list = goodsPriceListMapper.selectByGoodsIdDocId(example);
			if (redisOperatiorLogic.isJedisIsConnected()) {
				redisOperatiorLogic.setEx(key, list, getOrderRedisGroupNo("1"));
			}
		}
		return list;
	}
	

	public GoodsPriceListMapper getGoodsPriceListMapper() {
		return goodsPriceListMapper;
	}

	public void setGoodsPriceListMapper(
			GoodsPriceListMapper goodsPriceListMapper) {
		this.goodsPriceListMapper = goodsPriceListMapper;
	}

}
